package www.woniuxy.com.class112.controller;

import cn.hutool.core.bean.BeanUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import www.woniuxy.com.class112.form.userStanding.UserStandingFdAllForm;

import www.woniuxy.com.class112.form.userStanding.UserStandingrejectForm;
import www.woniuxy.com.class112.param.userStanding.UserStandingFdAllParam;
import www.woniuxy.com.class112.param.userStanding.UserStandingrejectParam;
import www.woniuxy.com.class112.service.UserStandingService;
import www.woniuxy.com.class112.util.JwtUtil;
import www.woniuxy.com.class112.util.Result;

import javax.annotation.Resource;

@RestController
@RequestMapping("/userStanding")
@Api(tags = "用户身份认证相关接口")
public class UserStandingController {
    @Resource
    private UserStandingService userStandingService;
    @GetMapping("/selectType")
    @ApiOperation("查询用户身份认证类型")
    private Result selectType(){
        return Result.success("查询成功",userStandingService.selectType());
    }

    @PostMapping("/selectUserStanding")
    @ApiOperation("查询用户身份认证信息")
    private Result selectUserStanding(@RequestBody UserStandingFdAllForm form)throws Exception{
        return Result.success("查询成功",userStandingService.selectUserStanding(BeanUtil.toBean(form, UserStandingFdAllParam.class)));
    }
    @GetMapping("/passUserStanding")
    @ApiOperation("通过用户身份认证")
    private Result passUserStanding(Long id,@RequestHeader String token){
        Long userId = JwtUtil.getUserId(token);
        userStandingService.passUserStanding(id,userId);
        return Result.success("通过成功",null);
    }
    @PostMapping("/UserStandingreject")
    @ApiOperation("驳回用户身份认证")
    private Result UserStandingreject(@RequestBody UserStandingrejectForm form,@RequestHeader String token){
        Long userId = JwtUtil.getUserId(token);
        UserStandingrejectParam param = BeanUtil.toBean(form, UserStandingrejectParam.class);
        param.setUserId(userId);
        System.out.println(param);
       userStandingService.rejectUserStanding(param);
        return Result.success("驳回成功",null);
    }
}
